package com.lej.core.daq

import com.lej.core.base.BaseApplication
import com.lej.core.common.PCacheInfo
import com.lej.core.common.SEX_BOY
import com.lej.core.common.SEX_GIRL
import com.lej.core.common.SEX_UNKNOWN

data class ActionEvent(
    @DAQOrder(10)
    val action: String,//事件名称
    @DAQOrder(20)
    val expand: String?,//扩展字段
    @DAQOrder(30)
    val page: String? = null,//事件发生的界面(一般在生命周期事件中传递)
    @DAQOrder(40)
    val sessionId: String = BaseApplication.shortSessionId,//
    @DAQOrder(50)
    val uid: String? = PCacheInfo.userId.toString(),//用户id,当用户帐号已登录的时候传,不登录为空
    @DAQOrder(60)
    val sex: Int? = PCacheInfo.sex,
    @DAQOrder(70)
    val time: Long = System.currentTimeMillis(),

    /**没有注解，不在action 埋点中上传*/
    val boyUid: String = if (PCacheInfo.sex == SEX_BOY) PCacheInfo.userId.toString() else "noBoy",
    val girlUid: String = if (PCacheInfo.sex == SEX_GIRL) PCacheInfo.userId.toString() else "noGirl",
    val unknownSexUid: String = if (PCacheInfo.sex == SEX_UNKNOWN) PCacheInfo.userId.toString() else "notUnknown"
)

/**标注友盟埋点上报的字符串内容
 *  以json数组形式的顺序上报
 *  标注需要在action详细信息埋点中上传*/
@Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class DAQOrder(
    /**  标注该属性的顺序  **/
    val order: Int
)
